#include "functions.h"

void initialize_elite(){

  if( strcmp( function_name, "f1") == 0 || strcmp( function_name, "f3") == 0 )
    elite.function_value = -DBL_MAX;
  else
    elite.function_value = DBL_MAX;

  elite.design_variables = ( double * ) malloc( sizeof( double ) * number_of_dimensions );
}

void print_elite(){
  int i;
    
  printf( "%5d\t%8d\t%.3e\t", number_of_generations, number_of_evaluations, elite.function_value);
  
  for( i=0;i<number_of_dimensions;i++ )
    printf( "%.4f\t", elite.design_variables[ i ] );
  
  printf( "\n" );

}

void elite_save(){
  int i;

  if( strcmp( function_name, "f1") == 0 || strcmp( function_name, "f3") == 0 )
    {
      if( elite.function_value < individuals[ 0 ].function_value ){
	elite.function_value = individuals[ 0 ].function_value;
	
	for( i=0;i<number_of_dimensions;i++ )
	  elite.design_variables[ i ] = individuals[ 0 ].design_variables[ i ];
      }
      
    } else{
    
    if( elite.function_value > individuals[ 0 ].function_value ){
      elite.function_value = individuals[ 0 ].function_value;

      for( i=0;i<number_of_dimensions;i++ )
	elite.design_variables[ i ] = individuals[ 0 ].design_variables[ i ];
    }
  }
}


